package com.JZ.QM.controller;

import com.JZ.QM.common.entity.PositionDetailEntity;
import com.JZ.QM.common.utils.CommonResult;
import com.JZ.QM.service.ComEarningRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * @author: cyc
 * @email cyc@gmail.com
 * @date: 2020/7/8 14:03
 */
@RefreshScope
@RestController
@Slf4j
@RequestMapping("/comEarningRecord")
public class ComEarningRecordController {

    @Resource
    ComEarningRecordService comEarningRecordService;


    /**
     * 通过财富账号id进行收益可视化
     * @param accountId
     * @return
     */
    @RequestMapping("/showComEarningRecordForChart")
    public CommonResult showComEarningRecordForChart(Long accountId){
        //组合收益可视化数据
        HashMap comEarningRecordForChart=new HashMap();
        comEarningRecordForChart=comEarningRecordService.showComEarningRecordForChart(accountId);
        if(comEarningRecordForChart.isEmpty()){
            return CommonResult.success().put("comEarning",new HashMap());
        } else {
            return CommonResult.success().put("comEarning",comEarningRecordForChart);
        }
    }

    /**
     * 展示持仓率
     * @param comBaseId
     * @return
     */
    @RequestMapping("/showComPositionRadioForUser")
    public CommonResult showComPositionRadioForUser(Long comBaseId){
        ArrayList<PositionDetailEntity> comPositionDetailEntities=new ArrayList<>();
        comPositionDetailEntities=comEarningRecordService.getComPositionDetailItems(comBaseId);

        return CommonResult.success().put("comPositionRadioForUser",comPositionDetailEntities);

    }
}
